package asTest;

import java.math.BigInteger;

public class AsTest {
    public static void main(String[] args) {
        System.out.println("==========================");
        System.out.println("'a' = " + (int)'a');
        System.out.println("'z' = " + (int)'z');
        System.out.println("'A' = " + (int)'A');
        System.out.println("'Z' = " + (int)'Z');
        System.out.println("'0' = " + (int)'0');
        System.out.println("==========================");

        String a = "10110";
        String b = "110110";
        char cha = '1';
        char chb = '0';
        int c = 0;
        char ch = '1'-'0';
      /*  System.out.println((cha + cha)%2 );*/
        System.out.println('1' - '0');
        System.out.println(c + '0');
        int i = 13;
        i >>= 1;
        while(i > 0){
            System.out.print(i + "\t");
            i >>= 1;
        }
        System.out.println("----------");
        String str = Integer.toString(8,2);
        System.out.println(str);
        System.out.println("=============================================");
        System.out.println(countPrimeSetBits(10,15));
       /* for(int j = 1; j < 10; j++){
            System.out.println(j +"--------->"+Integer.toString(j,2) +"------------>"+ primeNumLength(j));
        }*/

    }

    public static int countPrimeSetBits(int left, int right) {
        int result = 0;
        for(int i = left; i <= right; i++){
            int temp = i;
            boolean flag = isPrimeNum(primeNumLength(temp));
            if(flag == true){
                result ++;
            }
        }
        return result;
    }

    //判断 计算置位的个数
    public static int primeNumLength(int num){
        int number = 0;
        String str = Integer.toString(num,2);
        for(int i = 0; i < str.length(); i++){
            if(str.charAt(i) == '1'){
                number ++;
            }
        }
        return number;
    }

    //判断是否为质数
    public static boolean isPrimeNum(int number){
        if(number == 1 ) return false;
        double temp = Math.floor(Math.sqrt(number)); //平方根 向下取整
        for(int i =2; i < number; i++){
            if(number % i == 0){
                return false;
            }
        }
        return true;
    }



}
